﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Web.Services;
using Newtonsoft.Json;

namespace PropertyAppraisal.DoemsKanCha
{
    public partial class DomeQuwei : System.Web.UI.Page
    {
        private static BLL.DictionaryBll Dictionarybll = new BLL.DictionaryBll();
        private static BLL.LocationBll loca = new BLL.LocationBll ();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 反填详细信息
        /// </summary>
        /// <param name="pnum"></param>
        /// <returns></returns>
        [WebMethod]
        public static string BackData(string pnum)
        {
            var result = loca.GetListByPro(pnum);
            return JsonConvert.SerializeObject(result);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        [WebMethod]
        public static int submins(string ProjectNumber, string Location_East, string Location_West, string Location_North, string Location_South, int Location_Position, string Location_Traffic, int Location_Convenient, string Location_Humanity, int Location_Quality, string Location_Community, int Location_Mature, string Location_Facilities, int Location_Degree, int Location_Supporting, string Location_Explain)
        {
            Model.EALocation l = new Model.EALocation();
            l.projectNumber = ProjectNumber;
            l.location_East = Location_East;
            l.location_West = Location_West;
            l.location_North = Location_North;
            l.location_South = Location_South;
            l.location_Position = Location_Position;
            l.location_Traffic = Location_Traffic;
            l.location_Convenient = Location_Convenient;
            l.location_Humanity = Location_Humanity;
            l.location_Quality = Location_Quality;
            l.location_Community = Location_Community;
            l.location_Mature = Location_Mature;
            l.location_Facilities = Location_Facilities;
            l.location_Degree = Location_Degree;
            l.location_Supporting = Location_Supporting;
            l.location_Explain = Location_Explain;
            l.location_CreateTime = DateTime.Now;
            l.location_CreatePeople = "小黑";

            BLL.LocationBll bll = new BLL.LocationBll();
            if (bll.GetCount(ProjectNumber) == 0)
            {

                if (bll.Add(l))
                {
                    return 1;
                }
                else
                    return 0;
            }
            else
            {
                if (bll.Update(l))
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
                    
            }
        }


        /// <summary>
        /// 绑定位置环绕下拉框
        /// </summary>
        /// <returns></returns>
        public static string weiBD()
        {
            List<Model.SysDictionary> Dictionary = Dictionarybll.sb(5);
            var HtmlStr = "";
            for (var i = 0; i < Dictionary.Count; i++)
            {
                HtmlStr += "<option value=\"" + Dictionary[i].Dictionary_Number + "\">" + Dictionary[i].dictionary_Name + "</option>";
            }
            return HtmlStr;
        }


        /// <summary>
        /// 绑定交通便捷度下拉框
        /// </summary>
        /// <returns></returns>
        public static string jiaoBD()
        {
            List<Model.SysDictionary> Dictionary = Dictionarybll.sb(6);
            var HtmlStr = "";
            for (var i = 0; i < Dictionary.Count; i++)
            {
                HtmlStr += "<option value=\"" + Dictionary[i].Dictionary_Number + "\">" + Dictionary[i].dictionary_Name + "</option>";
            }
            return HtmlStr;
        }


        /// <summary>
        /// 绑定自然人文环境质量下拉框
        /// </summary>
        /// <returns></returns>
        public static string PersonBD()
        {
            List<Model.SysDictionary> Dictionary = Dictionarybll.sb(7);
            var HtmlStr = "";
            for (var i = 0; i < Dictionary.Count; i++)
            {
                HtmlStr += "<option value=\"" + Dictionary[i].Dictionary_Number + "\">" + Dictionary[i].dictionary_Name + "</option>";
            }
            return HtmlStr;
        }


        /// <summary>
        /// 绑定居住社区成熟度下拉框
        /// </summary>
        /// <returns></returns>
        public static string sheBD()
        {
            List<Model.SysDictionary> Dictionary = Dictionarybll.sb(8);
            var HtmlStr = "";
            for (var i = 0; i < Dictionary.Count; i++)
            {
                HtmlStr += "<option value=\"" + Dictionary[i].Dictionary_Number + "\">" + Dictionary[i].dictionary_Name + "</option>";
            }
            return HtmlStr;
        }
        /// <summary>
        /// 绑定配套设施下拉框
        /// </summary>
        /// <returns></returns>
        public static string peiBD()
        {
            List<Model.SysDictionary> Dictionary = Dictionarybll.sb(10);
            var HtmlStr = "";
            for (var i = 0; i < Dictionary.Count; i++)
            {
                HtmlStr += "<option value=\"" + Dictionary[i].Dictionary_Number + "\">" + Dictionary[i].dictionary_Name + "</option>";
            }
            return HtmlStr;
        }

        /// <summary>
        /// 绑定基础配套设施下拉框
        /// </summary>
        /// <returns></returns>
        public static string jichupeiBD()
        {
            List<Model.SysDictionary> Dictionary = Dictionarybll.sb(9);
            var HtmlStr = "";
            for (var i = 0; i < Dictionary.Count; i++)
            {
                HtmlStr += "<option value=\"" + Dictionary[i].Dictionary_Number + "\">" + Dictionary[i].dictionary_Name + "</option>";
            }
            return HtmlStr;
        }
    }
}